﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="../scripts/boot.js" type="text/javascript"></script>
    <script type="text/javascript">
         $.ajax({
             url: "../data/system.aspx?method=105",
             async: false,
             success: function (text) {
                 if (text == "no")
                     window.location = "../system/error.html";
                 else if (text == "out") {
                     var loginWindow = parent.mini.get("loginWindow");
                     if (!loginWindow.visible)
                         loginWindow.show();
                     var tabs = parent.mini.get("mainTabs");
                     var tab = tabs.getTab("tab$105");
                     tabs.removeTab(tab);
                 }
             }
        });
        var States = [{ id: 0, text: '未审核' }, { id: 1, text: '已审通过' }, { id: 2, text: '已审未通过' }, { id: -1, text: "全部"}];
        var State = [{ id: 0, text: '未审核' }, { id: 1, text: '<font color="Green">已审通过</font>' }, { id: 2, text: '<font color="Red">已审未通过</font>'}];
    </script>
</head>
<body>
    <div class="mini-fit" >
        <div id="divList" class="mini-fit" >
            <div class="mini-toolbar" style="border-bottom:0;">
                <table>
                    <tr>
                        <td>
                            紧缺人才:
                            <input id="key" class="mini-textbox" style="width:100px" emptytext="关键字"/>
                            类型:
                            <input id="state" class="mini-combobox" data="States" value="0" style="width:100px"/>
                            <a class="mini-button" iconCls="icon-search" plain="true" onclick="search()">查询</a>
                            <span class="separator"></span>
                            <a class="mini-button" plain="true" iconcls="icon-ok" onclick="checkRows(1)">审核通过</a>
                            <a class="mini-button" plain="true" iconcls="icon-no" onclick="checkRows(2)">审核不通过</a>
                            <a class="mini-button" plain="true" iconcls="icon-remove" onclick="delRows()">删除</a>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="mini-fit">
                <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowresize="true" url="../data/system.aspx?method=GetNeedRecruitList" idField="id" multiSelect="true" sizeList="[15,20,50,100]" pageSize="15">
                    <div property="columns">
                        <div type="checkcolumn"></div>
                        <div cellCls="actionIcons" name="action" width="50px" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>
                        <div field="re_name" width="120px" headerAlign="center" align="center" allowSort="true" renderer="onNameRenderer">紧缺人才</div>
                        <div field="cu_name" headerAlign="center" align="center" allowSort="true" renderer="onCNameRenderer">单位名称</div>
                        <div field="re_needstate" width="80px" headerAlign="center" align="center" allowSort="true" renderer="onPastRenderer" >状态</div>
                        <div field="re_num" width="60px" headerAlign="center" align="center" allowSort="true">人数</div>
                        <div field="job" width="80px" headerAlign="center" align="center" allowSort="true">岗位类别1</div>
                        <div field="re_sex" width="50px" align="center" headerAlign="center" allowSort="true" renderer="onSexRenderer">性别</div>
                        <div field="re_inserttime" width="80px" allowSort="true" align="center" headerAlign="center" dateFormat="yyyy-MM-dd">发布时间</div>
                    </div>
                </div>
            </div>
        </div>
        <div id="editForm" class="form" style="display:none">
            <fieldset style="border: solid 1px #aaa; width: 740px">
                <legend><strong>职位详细信息</strong><span class="red">( 带 * 号的必须填写)</span></legend>
                <input class="mini-hidden" name="re_no" />
                <input class="mini-hidden" name="re_cuno" />
                <input class="mini-hidden" name="cu_name" />
                <table style="width: 100%;">
                    <tr>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;岗位名称：
                        </td>
                        <td>
                            <input class="mini-textbox" name="re_name" style="width: 280px" required="true" />
                        </td>
                        <td colspan="2" style="text-align: left">
                            <input name="re_need" class="mini-checkbox" text="紧缺岗位"/>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;招聘人数：
                        </td>
                        <td colspan="3">
                            <input class="mini-textbox" name="re_num" style="width: 50px" required="true" vtype="int" />&nbsp;人（0
                            表示若干，只能填写数字，切换成英文输入）
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;性别：
                        </td>
                        <td>
                            <input class="mini-combobox" name="re_sex" style="width: 100px" required="true" textfield="di_name"
                                required="true" valuefield="di_code" url="../data/system.aspx?method=CbxSex" />
                        </td>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;工作性质：
                        </td>
                        <td>
                            <input class="mini-combobox" name="re_kind" style="width: 100px" required="true"
                                textfield="di_name" required="true" valuefield="di_code" url="../data/system.aspx?method=CbxKind" />
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle" style="width: 120px;">
                            <span style="color: Red">*</span>&nbsp;&nbsp;学历：
                        </td>
                        <td style="width: 200px;">
                            <input class="mini-combobox" name="re_edu" style="width: 100px" required="true" textfield="di_name"
                                required="true" valuefield="di_code" url="../data/system.aspx?method=CbxEdu" />&nbsp;&nbsp;
                            <input name="re_edu2" class="mini-checkbox" checked="true" text="以上"/>
                        </td>
                        <td class="tdtitle" style="width: 120px">
                            <span style="color: Red">*</span>&nbsp;&nbsp;招聘对象：
                        </td>
                        <td style="width: 200px">
                            <input class="mini-combobox" name="re_target" style="width: 180px" required="true"
                                textfield="di_name" required="true" valuefield="di_code" url="../data/system.aspx?method=CbxTarget" />
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;岗位类别1：
                        </td>
                        <td>
                            <input class="mini-combobox" style="width: 180px;" name="re_jobtype1" textfield="jt_name"
                                required="true" valuefield="jt_id" url="../data/system.aspx?method=CbxPJobType" onvaluechanged="onType1Changed"/>
                        </td>
                        <td class="tdtitle">
                            岗位类别11：
                        </td>
                        <td>
                            <input class="mini-combobox" style="width: 180px;" name="re_jobtype11" textfield="jt_name"
                                valuefield="jt_id"/>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;岗位类别2：
                        </td>
                        <td>
                            <input class="mini-combobox" style="width: 180px;" name="re_jobtype2" textfield="jt_name"
                                required="true" valuefield="jt_id" url="../data/system.aspx?method=CbxPJobType" onvaluechanged="onType2Changed"/>
                        </td>
                        <td class="tdtitle">
                            岗位类别22：
                        </td>
                        <td>
                            <input class="mini-combobox" style="width: 180px;" name="re_jobtype22" textfield="jt_name"
                                valuefield="jt_id"/>
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            年龄：
                        </td>
                        <td colspan="3">
                            <input class="mini-textbox" style="width: 80px;" name="re_age" />（空白表示不限）
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;待遇：
                        </td>
                        <td colspan="3">
                            <input class="mini-textbox" name="re_pay1" style="width: 60px" required="true" vtype="int" />
                            —
                            <input class="mini-textbox" name="re_pay2" style="width: 60px" vtype="int" />&nbsp;元/月
                            （后框可空，不低于全市最低工资标准：850）
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;工作地区：
                        </td>
                        <td>
                            <input class="mini-combobox" name="re_area" style="width: 100px" required="true"
                                textfield="di_name" required="true" valuefield="di_code" url="../data/system.aspx?method=CbxArea" />
                        </td>
                        <td class="tdtitle">
                            <span style="color: Red">*</span>&nbsp;&nbsp;有效期：
                        </td>
                        <td>
                            <input class="mini-textbox" name="re_effecttime" style="width: 60px" required="true"
                                vtype="int" />&nbsp;天
                        </td>
                    </tr>
                    <tr>
                        <td class="tdtitle">
                            其他要求：
                        </td>
                        <td colspan="3">
                            <input class="mini-textarea" name="re_memo" style="width: 570px; height: 80px" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align:center;padding:5px;">
<!--                            <a class="mini-button" style="width:60px;" onclick="updateRow()">保存</a>
                            <span style="display:inline-block;width:25px;"></span>-->
                            <a class="mini-button" style="width:60px;" onclick="cancelRow()">取消</a>
                        </td>
                    </tr>
                </table>
            </fieldset>
        </div>
    </div>
<script type="text/javascript">
    $.ajaxSetup({
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        complete: function (XMLHttpRequest, textStatus) {
            if (XMLHttpRequest.responseText == "out") {
                var loginWindow = parent.mini.get("loginWindow");
                if (!loginWindow.visible)
                    loginWindow.show();
            }
        }
    });

    mini.parse();

    var grid = mini.get("datagrid1");
    search();

    function search() {
        var key = mini.get("key").getValue();
        var state = mini.get("state").getValue();
        grid.load({ key: key, state: state });
        grid.sortBy("re_no", "desc");
    }

    function onActionRenderer(e) {
        var record = e.record;
        var s = '<span class="icon-edit actionspan" title="查看" onclick="editRow(' + record._uid + ')"></span><span class="separator"></span><span class="icon-remove actionspan" title="删除" onclick="delRow(' + record._uid + ')"></span>';
        return s;
    }

    function onNameRenderer(e) {
        //var s = '<a class="linelink" href="../../Web/Job/' + e.record.re_no + '.html" target="_blank">' + e.record.re_name + '</a>';
        var s = '<a class="linelink">' + e.record.re_name + '</a>';
        if (e.record.re_hide == 1)
            s = s + "<span style='color:Red'>[隐]</span>";
        var myDate = new Date();

        if (e.record.re_endtime < myDate)
            s = s + "<span style='color:#0088ff'>[过期]</span>";
        return s;
    }

    function onCNameRenderer(e) {
        //var s = '<a class="linelink" href="../../Web/Company/' + e.record.re_cuno + '.html" target="_blank">' + e.record.cu_name + '</a>';
        var s = '<a class="linelink">' + e.record.cu_name + '</a>';
        if (e.record.cu_hide == 1)
            s = s + "<span style='color:red'>[隐]</span>";
        var myDate = new Date();

        if (e.record.cu_endtime < myDate)
            s = s + "<span style='color:#0088ff'>[过期]</span>";
        return s;
    }

    function onPastRenderer(e) {
        for (var i = 0; i < State.length; i++) {
            var s = State[i];
            if (s.id == e.value)
                return s.text;
        }
        return "";
    }

    function onSexRenderer(e) {
        if (e.record.re_sex == 0)
            return '男';
        else if (e.record.re_sex == 1)
            return '女';
        else
            return '不限';
    }
    function addRow() {
        var form = new mini.Form("#editForm");
        form.clear();
        mini.getbyName("re_cuno").setValue(cuno);
        $("#divList").hide();
        $("#editForm").show();
    }

    function editRow(row_uid) {
        var row = grid.getRowByUID(row_uid);
        if (row) {
            $("#divList").hide();
            $("#editForm").show();
            var form = new mini.Form("#editForm");
            form.clear();
            form.loading();
            $.ajax({
                url: "../data/system.aspx?method=GetRecruit",
                data: { id: row.re_no },
                success: function (text) {
                    form.unmask();
                    if (text == "out") {
                        $("#editForm").hide();
                        $("#divList").show();
                        var loginWindow = parent.mini.get("loginWindow");
                        if (!loginWindow.visible)
                            loginWindow.show();
                        return;
                    }
                    var o = mini.decode(text);
                    form.setData(o);
                    var type1 = mini.getbyName("re_jobtype1").getValue();
                    var url = "../data/system.aspx?method=CbxCJobType&id=" + type1
                    mini.getbyName("re_jobtype11").setUrl(url);
                    var type2 = mini.getbyName("re_jobtype2").getValue();
                    url = "../data/system.aspx?method=CbxCJobType&id=" + type2
                    mini.getbyName("re_jobtype22").setUrl(url);
                    if (o.re_edu2 == "") {
                        mini.getbyName("re_edu2").setChecked(false);
                    } else {
                        mini.getbyName("re_edu2").setChecked(true);
                    }
                }
            });
        }
    }

    function updateRow() {
        var form = new mini.Form("#editForm");
        form.validate();
        if (form.isValid() == false)
            return;
        var o = form.getData();
        var json = mini.encode(o);
        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '保存中，请稍后...' });

        $.ajax({
            url: "../data/system.aspx?method=SaveRecruit",
            type: "post",
            data: { data: json },
            success: function (ret) {
                mini.unmask(document.body);
                if (ret == "out") {
                    var loginWindow = parent.mini.get("loginWindow");
                    if (!loginWindow.visible)
                        loginWindow.show();
                    return;
                }
                if (ret == 1) {
                    $("#divList").show();
                    $("#editForm").hide();
                    form.clear();
                    ShowMessage("系统提示", "招聘职位保存成功！", 1);
                    grid.reload();
                }
                else if (ret == 0) {
                    $("#divList").show();
                    $("#editForm").hide();
                    form.clear();
                    ShowMessage("系统提示", "该招聘职位已不存在，请确认！", 2);
                    grid.reload();
                }
                else
                    ShowMessage("系统提示", "招聘职位保存失败！", 3);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                mini.unmask(document.body);
                ShowMessage("系统提示", "招聘职位保存失败！", 3);
            }
        });
    }

    function cancelRow() {
        var form = new mini.Form("#editForm");
        form.clear();
        $("#divList").show();
        $("#editForm").hide();
    }

    function delRow(row_uid) {
        var row = grid.getRowByUID(row_uid);
        if (row) {
            mini.confirm("确定删除此紧缺人才吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '删除中，请稍后...' });
                        $.ajax({
                            url: "../data/system.aspx?method=DeleteTalent",
                            data: { id: row.re_no },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "紧缺人才删除成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "紧缺人才删除失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "紧缺人才删除失败！", 3);
                            }
                        });
                    }
                }
            );
        }
    }

    function delRows() {
        var rows = grid.getSelecteds();
        if (rows.length > 0) {
            mini.confirm("确定删除所选的紧缺人才吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '删除中，请稍后...' });
                        var ids = "";
                        for (var i = 0; i < rows.length; i++) {
                            ids += rows[i].re_no + ',';
                        }

                        $.ajax({
                            url: "../data/system.aspx?method=DeleteTalent",
                            type: "post",
                            data: { id: ids },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "紧缺人才删除成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "紧缺人才删除失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "紧缺人才删除失败！", 3);
                            }
                        });
                    }
                }
            );
        } else
             ShowMessage("系统提示", "请选择需要删除的紧缺人才！", 2);
    }


    //批量审核
    function checkRows(state) {
        var rows = grid.getSelecteds();
        if (rows.length > 0) {
            mini.confirm("确定要审核所选的紧缺人才吗？", "系统提示",
                function (action) {
                    if (action == "ok") {
                        mini.mask({ el: document.body, cls: 'mini-mask-loading', html: '操作中，请稍后...' });
                        var ids = "";
                        for (var i = 0; i < rows.length; i++) {
                            ids += rows[i].re_no + ',';
                        }

                        $.ajax({
                            url: "../data/system.aspx?method=CheckTalent",
                            type: "post",
                            data: { id: ids, state: state },
                            success: function (ret) {
                                mini.unmask(document.body);
                                if (ret == "out") {
                                    var loginWindow = parent.mini.get("loginWindow");
                                    if (!loginWindow.visible)
                                        loginWindow.show();
                                    return;
                                }
                                if (ret >= 0) {
                                    ShowMessage("系统提示", "紧缺人才审核成功！", 1);
                                    grid.reload();
                                }
                                else
                                    ShowMessage("系统提示", "紧缺人才审核失败！", 3);
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                mini.unmask(document.body);
                                ShowMessage("系统提示", "紧缺人才审核失败！", 3);
                            }
                        });
                    }
                }
            );
        } else
            ShowMessage("系统提示", "请选择需要审核的紧缺人才！", 2);
    } 
 </script>
</body>
</html>


